import request from '@/utils/requestA'
/**
 * 注册接口
 * @param {*} param0 { username: 用户名, password: 密码 }
 * @returns Promise对象
 */
// export const login = ({ username, password }) => {
//   return request({
//     url: '/login',
//     method: 'Get',
//     params: {
//       username,
//       password
//     }
//   })
export const getAdminInfoByPhone = (admin_phone) => {
  return request({
    url: '/adminInfo/getAdminInfoByPhone',
    method: 'post',
    params:{
      admin_phone
    }
  })
}
export const getadmins = () => {
  return request({
    url: '/adminInfo/getAllUsers',
    method: 'Get'
  })
}
export const getdept = () => {
  return request({
    url: '/sys/dept',
    method: 'Get'
  })
}
// pagenum: 当前页码数, pagesize: 当前页条数
// export const inituser = (pagenum, pagesize) => {
//   return request({
//     url: '/sys/inituserinfo',
//     method: 'Get',
//     params: {
//       pagenum,
//       pagesize

//     }
//   })
// }

export const registerAPI = (nickname, username, password) => {
  return request({
    url: '/register',
    method: 'post',
    data: {
      nickname,
      username,
      password
    }
  })
}
//学生登录
export const login = ({ _phone, stu_password }) => {
  return request({
    url: '/userInfo/AdminLogin',
    method: 'get',
    params: {
      stu_phone,
      stu_password
    }
  })
}
// page: 当前页码数, limit: 当前页条数
export const inituser = (page, limit) => {
  return request({
    url: '/adminInfo/findAdminByPageAndLimit',
    method: 'Get',
    params: {
      page,
      limit
    }
  })
}

// 编辑用户
export const editAdmin = (adminId,
  adminNum,
  adminName,
  adminAge,
  adminSex,
  adminAddress,
  adminProfession,
 adminWorkStatus,
 adminPhone,
 adminPassword,
 adminAccess) => {
  return request({
    url: '/adminInfo/updateAdminById',
    method: 'post',
    data: {
      adminId,
      adminNum,
      adminName,
      adminAge,
      adminSex,
      adminAddress,
      adminProfession,
     adminWorkStatus,
     adminPhone,
     adminPassword,
     adminAccess
    }
  })
}
export const updateAdminStatus = (id, status) => {
  return request({
    url: '/updateAdminStatus',
    method: 'post',
    data: {
      id, status
    }
  })
}
export const addAdminApI = (adminNum, adminName, adminAge, adminSex, adminAddress, adminProfession, adminWorkStatus ,adminPhone, adminPassword,adminAccess ) => {
  return request({
    url: '/adminInfo/addAdmins',
    method: 'post',
    data: {
        adminNum, adminName, adminAge, adminSex, adminAddress, adminProfession, adminWorkStatus ,adminPhone, adminPassword ,adminAccess
    }
  })
}

export const deleteAdminByIdApI = (adminId) => {
  return request({
    url: '/adminInfo/deleteAdminById',
    method: 'post',
    data: {
      adminId
    }
  })
}
export const deleteAdminsApI = (ids) => {
  return request({
    url: '/adminInfo/deleteAdmins',
    method: 'post',
    data: {
      ids
    }
  })
}

// export const findAdminByNameApI = (admin_phone) => {
//   return request({
//     url: '/userInfo/findAdminByName',
//     method: 'get',
//     params:{
//       admin_phone
//     }
    
//   })
// }
export const findAdminByNameApI = (adminName) => {
  return request({
    url: '/adminInfo/findAdminByName',
    method: 'get',
    params:{
      adminName
    }
    
  })
}

export const updatePwdAPI = (id, password) => {
  return request({
    url: '/updateAdminPasswordById',
    method: 'post',
    data: {
      id, password
    }
  })
}
